﻿@{
    ViewBag.Title = "客户预付款";
    Layout = "~/Views/Shared/InfoMaste.cshtml";
}

<table id="dg" class="easyui-datagrid" style="width:100%; height: 750px;"
       url="/Finance/GetLKCustomerPrePaymentPageList" toolbar="#tb" title="客户预付款" rownumbers="true" pagination="true"
       pagelist="[15]" fitcolumns="true" singleselect="true">
    <thead>
        <tr>
            <th field="BillNo" align="right" width="10%">
                单据编号
            </th>
            <th field="CustomerName" align="right" width="10%">
                客户名称
            </th>
            <th field="CreateTime" align="right" width="10%">
                日期
            </th>
            <th field="PreAmount" align="right" width="10%">
                预付金额
            </th>
            <th field="ModifyUser" align="right" width="10%">
                修改人
            </th>
            <th field="Remark" align="right" width="10%">
                备注
            </th>
        </tr>
    </thead>
</table>
<div id="tb" style="padding: 3px; height: auto;">
    <span>单据编号</span>
    <input id="BillNo" class="easyui-textbox " style="width: 173px; height: 30px;" />
    <span>客户名称</span>
    <input type="hidden" id="hdselectKeyword" />
    <input name="SelectCustomer" id="SelectCustomer" class="easyui-combobox" style="width: 173px; height: 30px;" />
    <div>
        <a href="javascript:" class="easyui-linkbutton" iconcls="icon-add" plain="true" onclick="addLKCustomerPrePayment()">新建</a>
        <a href="javascript:" class="easyui-linkbutton" iconcls="icon-edit" plain="true" onclick="editLKCustomerPrePayment()">编辑</a>
        <a href="javascript:" class="easyui-linkbutton" iconcls="icon-no" plain="true" onclick="delLKCustomerPrePayment()">删除</a>
        <a href="javascript:" class="easyui-linkbutton" plain="true" iconcls="icon-search" onclick="doSearch()">查询</a>
    </div>
</div>

<script src="~/Js/Global.js"></script>
<script language="javascript" type="text/javascript">
    $(function () {
        InitSelectCustomer();
    });

    $('#dg').datagrid({
        // 其他配置...
        onDblClickRow: function (rowIndex, rowData) {
            editLKCustomerPrePayment();
        }
    });

    function addLKCustomerPrePayment() {
        window.location.href = "/Finance/AddLKCustomerPrePayment";
    }


    function doSearch() {
        $('#dg').datagrid('load', {
            BillNo: $('#BillNo').val(),
            CustomerId: $('#SelectCustomer').combobox('getValue')
        });
    }

    function querycustomer() {
        $("#SelectCustomer").combogrid("grid").datagrid("reload", { "CustomerName": $("#SelectCustomerText").val() });
    }
    function querycustomer2() {
        $("#CustomerId").combogrid("grid").datagrid("reload", { "CustomerName": $("#SelectCustomerText2").val() });
    }

    function editLKCustomerPrePayment() {
        var row = $('#dg').datagrid('getSelected');
        if (!row) {
            Helper.Show('请选择需要编辑的信息?');
            return;
        }
        window.location.href = "/Finance/EditLKCustomerPrePayment?id=" + row.Id;
    }

    function delLKCustomerPrePayment() {
        var row = $('#dg').datagrid('getSelected');
        if (!row) {
            Helper.Show('请选择需要删除的信息?');
            return false;
        }
        $.messager.confirm('提示信息', '您确认要删除吗?', function (r) {
            if (!r) { return false; }
            $.post("/Finance/DeleteLKCustomerPrePayment", { id: row.Id }, function (json) {
                Helper.Show(json.Msg);
                if (json.Success) {
                    doSearch();
                }
            });
        });
    }

    function saveLKCustomerPrePayment() {
        $('#fm').form('submit', {
            url: url,
            onSubmit: function () {
                return $(this).form('validate');
            },
            success: function (json) {
                var json = eval('(' + json + ')');
                Helper.Show(json.Msg);
                if (json.Success) {
                    $('#fm').form('clear');
                    $('#dlg').dialog('close');
                    $('#dg').datagrid('reload');
                }
            }
        });
    }

    function formatter_IsValid(value, rowData, rowIndex) {
        return rowData.IsValid ? '启用' : '停用';
    }

    function formatter_IsByTon(value, rowData, rowIndex) {
        return rowData.IsByTon ? '是' : '否';
    }

    function formatter_ColdUnitPrice(value, rowData, rowIndex) {
        return rowData.ColdUnitPrice.toFixed(2);
    }

    function formatter_BeginTime(value, rowData, rowIndex) {
        return formatdate(rowData.BeginTime);
    }
    function formatter_EndTime(value, rowData, rowIndex) {
        return formatdate(rowData.EndTime);
    }
    function formatter_ContractTime(value, rowData, rowIndex) {
        return formatdate(rowData.ContractTime);
    }
</script>



